package edu.udel.mboch.towerdefense;

public class TimeActor implements Actor
{
	private static final long serialVersionUID = 26763991530757346L;
	private long lastTimeMove;
	private long spawnTimer;
	private long incomeTimer;
	
	public TimeActor()
	{
		lastTimeMove = System.currentTimeMillis();
		spawnTimer = 0;
		incomeTimer = 0;
	}
	
	public TDMove getNextMove(TDState state)
	{
		long newTime = System.currentTimeMillis();
		long time = newTime - lastTimeMove;
		lastTimeMove = newTime;
		spawnTimer += time;
		incomeTimer += time;
		boolean spawn = false;
		boolean income = false;
		if(spawnTimer>1000)
		{
			spawnTimer = 0;
			spawn = true;
		}
		if(incomeTimer>5000)
		{
			incomeTimer = 0;
			income = true;
		}
		return new TimeMove(time, spawn, income);
	}

}
